
<template>
  <div o-Container>
    <o-list v-bind:source="list.sensorType"
            v-bind="{created:create,modified:modify,searched:search}"/>
    <o-dialog v-bind:source="panel" v-bind="{opened:load,closed:load}">
      <template slot="content">
        <o-item v-bind:source="item.sensorType" v-bind="{saved:save,backed:back}"></o-item>
      </template>
    </o-dialog>
  </div>
</template>

<script>
  export default {
    name: "mms_iot_sensor_list", /* 这个name暂时不知道用啥用，根据官方文档说的是方便排错的 */
    data() {
      return {
        octopus: this.$parent.octopus,
        list: {
          sensorType: {
            data: {
              id: 66, // 菜单表的八爪鱼ID
              cellData: [
                {name: "SystemID", width: 150, searchKey: "="},
                {name: "Name", width: 150, searchKey: "LIKE"},
                {name: "Code", width: 150, searchKey: "LIKE"},
                {name: "Icon", width: 150},
                {name: "IconColor", width: 100},
                {name: "Sort", width: 100},
                {name: "Enable", width: 100, searchKey: "="},
                {name: "CreateTime", width: 150},
              ],
            }
          },
        },
        item: {
          sensorType: {
            // 以下参数默认由组件内部创建，但是如果有需要，开发人员可在这里提前设置，组件将按照您的预期渲染。
            // cache: false,
            // control: null,
            // dataExtend: null,
            data: {
              id: 66,
              value: "",
              cellData: [
                {name: "SystemID"},
                {name: "Code"},
                {name: "Name"},
                {name: "Icon"},
                {name: "IconColor"},
                {name: "Sort"},
                {name: "Enable"},
                {name: "CreateTime"},
              ]
            },
          },
        },
        panel: {
          visible: false,
        },
      }
    },
    methods: {
      create: function () {
        this.item.sensorType.data.value = null;
        this.item.sensorType.control.load();

        this.panel.visible = true;
      },
      output: function (data) {
        this.octopus.tips.success('下载成功。');
        // 导出以后，回调这里给客户端操作。
        // 核心思想是cellData包含search数据（不管有没有），回传以后发送export指令，后台api会直接返回导出的数据提供下载。
      },
      search: function (cell) {

      },
      modify: function (row) {
        this.item.sensorType.data.value = row.ID; //赋值
        this.item.sensorType.control.load(); //刷新

        this.panel.visible = true; //打开
      },
      view: function (row) {
        alert("view key: " + JSON.stringify(row)); //提示
      },
      del: function (row) {
        alert("del key: " + JSON.stringify(row)); //提示
      },
      save: function (data) {
        this.octopus.tips.success(data);
        // 刷新list
        this.list.sensorType.control.load(); //刷新
        this.back(); //返回
      },
      back: function () {
        this.panel.visible = false; //取消
      }
    },
    props: ["oData"] //数据
  }
</script>
